--- 状态
---
--- @class BasePool
BasePool = ClientFight.CreateClass("BasePool")
local BasePool = BasePool

--- @public
--- @return BasePool
function BasePool:ctor()
    -- ----------------基础状态属性--------------------
    self.type = BuffPoolEnum.NONE;                --类型
    --当前*/
    self.current = 0;
    --最大*/
    self.max = 0;


end
---@param buff FighterBuff
function BasePool:setCurrent(newValue, buff)
    if buff.skillUUID ~= nil then
        self.setCurrent1(newValue, buff)
    end
    if (newValue < 0) then
        newValue = 0;
    end
    local old = self.current;
    local change = newValue - old;
    if (change > 0) then
        local target = buff.target
        local fight = target.fight;
        if (type == BuffPoolEnum.DEFEAT)  then
        local result = FightResult.New()
        result:setDamage(change);
        EventManager.notifyEventListener(fight, FightEventEnum.DEFEAT_ADD, target.fighterId, buff,0, result);
        change = result:getDamage();

        end
    end
    self.current = self.current + change;
    if (self.type == BuffPoolEnum.DEFEAT) then
        buff.target.defeatPool = buff.target.defeatPool + change
        local target = buff.target;
        local fight = target.fight;
        EventManager.notifyEventListener(fight, FightEventEnum.DEFEAT_AFTER_REDUCE, target.fighterId);
    end
    return self.current;
end
---@param buff Buff
function BasePool:setCurrent1(current, buff)
    if (current < 0) then
        current = 0;
    end
    local old = self.current;
    self.current = current;
    local change = current - old;
    if (self.type == BuffPoolEnum.DEFEAT) then
        buff.target.defeatPool = buff.target.defeatPool + change
    end
end

function BasePool:setType(type)
    self.type = type;
end

function BasePool:setMax(max)
    self.max = max;
end